/*
 * @(#) SeqgenSettingManager.java  1.0  2004-3-18
 *
 * Copyright 2003 by LongTop Corporation.
 * 2669 XieTu Road, ShangHai, PRC 200030
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * LongTop Corporation ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with LongTop.
 */

package com.cnc.bas.seq;

import com.cnc.bas.dao.IBasDao;
import com.cnc.ssm.model.PwSqSetting;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

/**
 * @author Du bf
 * @version 1.0  2004-3-18
 */
public class SeqgenSettingManager {
    private static SeqgenSettingManager ourInstance = null;

    private IBasDao basDao;

    public IBasDao getBasDao() {
        return basDao;
    }

    public void setBasDao(IBasDao basDao) {
        this.basDao = basDao;
    }

    public synchronized static SeqgenSettingManager getInstance(IBasDao basDao) {
        if (ourInstance == null) {
            ourInstance = new SeqgenSettingManager(basDao);
        }
        return ourInstance;
    }

    public SeqgenSettingManager() {

    }

    private SeqgenSettingManager(IBasDao basDao) {
        List setting = basDao.listSeqSetting();
        Iterator iter = setting.iterator();
        hs = new HashMap();
        lastValue = new HashMap();
        while (iter.hasNext()) {
            PwSqSetting seq = (PwSqSetting) iter.next();
            hs.put(seq.getSqId().trim(), seq);
        }
    }

    public PwSqSetting getSeqSetting(String key) {
        return (PwSqSetting) hs.get(key);
    }

    private HashMap hs = null;
    private HashMap lastValue = null;

    public HashMap getLastValue() {
        return lastValue;
    }

    public void setLastValue(HashMap lastValue) {
        this.lastValue = lastValue;
    }
}
